#define _CRT_SECURE_NO_WARNINGS 1
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int n;
    cin >> n;
    string str;
    cin >> str;
    vector<char> table;
    table.push_back(str[0]);
    for (int i = 1; i < str.size(); i++)
    {
        if (str[i] >= table.back()) table.push_back(str[i]);
        else
        {
            int left = 0, right = table.size() - 1;
            while (left < right)
            {
                int mid = (left + right) / 2;
                if (str[i] < table[mid]) right = mid;
                else left = mid + 1;
            }
            table[left] = str[i];
        }
    }
    cout << n - table.size();
    return 0;
}